/*******************************************************************************
  * 文件：BuzCtrl.c
  * 作者：djy
  * 版本：v1.0.0
  * 日期：2020-11-28
  * 说明：蜂鸣器控制相关
*******************************************************************************/
#ifndef _BUZ_CTRL_H
#define _BUZ_CTRL_H

#include "Typedefine.h"
#include "Constant.h"
#include "Macro.h"

// 按键
#define    u16BUZ_KEY_PRESS_ON_MS        ((U16)  100)
#define    u16BUZ_KEY_PRESS_OFF_MS       ((U16)    0)
#define    u8BUZ_KEY_PRESS_REPEAT        ((U8)    1)

// 干烧
#define    u16BUZ_DRY_FIRE_ON_MS         ((U16) 2000)
#define    u16BUZ_DRY_FIRE_OFF_MS        ((U16) 1000)
#define    u8BUZ_DRY_FIRE_REPEAT         ((U8)    7)

// 温度探头异常
#define    u16BUZ_SENSOR_ERR_ON_MS       ((U16) 1000)
#define    u16BUZ_SENSOR_ERR_OFF_MS      ((U16) 1000)
#define    u8BUZ_SENSOR_ERR_REPEAT       ((U16)   10)

// 副线圈异常
#define    u16BUZ_FXQ_ERR_ON_MS          ((U16) 1000)
#define    u16BUZ_FXQ_ERR_OFF_MS         ((U16) 2000)
#define    u8BUZ_FXQ_ERR_REPEAT          ((U8)   255)

// 电压异常
#define    u16BUZ_VOLTAGE_ERR_ON_MS      ((U16) 1000)
#define    u16BUZ_VOLTAGE_ERR_OFF_MS     ((U16) 1000)
#define    u8BUZ_VOLTAGE_ERR_REPEAT      ((U8)     5)

// 电压异常
#define    u16BUZ_FIRE_OFF_ON_MS         ((U16) 2000)
#define    u16BUZ_FIRE_OFF_OFF_MS        ((U16) 1000)
#define    u8BUZ_FIRE_OFF_REPEAT         ((U8)     3)

// 定时时间到
#define    u16BUZ_TIME_OUT_ON_MS         ((U16)  500)
#define    u16BUZ_TIME_OUT_OFF_MS        ((U16)  500)
#define    u8BUZ_TIME_OUT_REPEAT         ((U8)    10)

// 点火失败
#define    u16BUZ_FIRE_FAIL_ON_MS        ((U16)  250)
#define    u16BUZ_FIRE_FAIL_OFF_MS       ((U16)  250)
#define    u8BUZ_FIRE_FAIL_REPEAT        ((U8)    40)

typedef enum
{
    eBUZ_VALID = 1,     // 有效提示音
    eBUZ_DRY_FIRE,      // 干烧提示音
    eBUZ_SENSOR_ERR,    // 温度探头异常提示音
    eBUZ_FXQ_ERR,       // 副线圈异常
    eBUZ_VOLTAGE_ERR,   // 电压异常
    eBUZ_FLAMEOUT,      // 意外熄火
    eBUZ_TIME_OUT,      // 定时结束
    eBUZ_FIRE_FAIL,     // 点火失败
}BuzType_te;

typedef struct
{
    U16         u16BuzOnMs;
    U16         u16BuzOffMs;
    U8          u8RepeatCnt;
    BuzType_te  eBuzType;
}BuzCtrlPara_ts;

typedef struct
{
    U32     u32Tick;
    BuzCtrlPara_ts sBuzCtrlPara;
    Bool    bBuzState;
}BuzCtrl_ts;

void BuzCtrl_Hook1MS(void);
void BuzCtrl(BuzType_te eBuzType);
void BuzStop(void);
void BuzInit(void);

#endif

